package com.itheima.util;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;

/**
 * SqlSession工具类
 */
public class SqlSessionUtils {

    public static SqlSession getSqlSession() {
        try {
            return new SqlSessionFactoryBuilder().build(Resources.getResourceAsReader("sqlMapConfig.xml")).openSession(true);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}

